

#include <cstdint>
#include <string>
#include <iostream>

#include <tenacitas.id.concept/string2number.h>

#include "runtest.h"



namespace tenacitas {
    /** ==> namespace for the project */
    namespace id {
        /** ==> application, bussiness, display, interaction, process, storage,
            transmittion */
        namespace concept {
            
            struct string2number_tester {

            private:

                static bool test1() {
                    
                    int16_t i1 = -239;
                    std::string s("-239");

                    int16_t i2 = s2n<int16_t>()(s);

                    std::cerr << "i2 = " << i2 << std::endl;

                    return (i1 == i2 ? true : false);
                }

                static bool test2() {
                    
                    int16_t i1 = -239;
                    const char * s("-239");

                    int16_t i2 = s2n<int16_t>()(s);

                    std::cerr << "i2 = " << i2 << std::endl;

                    return (i1 == i2 ? true : false);
                }

                static bool test3() {
                    
                    int16_t i1 = -239;
                    std::string s("2");

                    int16_t i2 = s2n<int16_t>()(s);

                    std::cerr << "i2 = " << i2 << std::endl;

                    return (i1 != i2 ? true : false);
                }

                static bool test4() {
                    
                    int16_t i1 = -239;
                    const char * s("9");

                    int16_t i2 = s2n<int16_t>()(s);

                    std::cerr << "i2 = " << i2 << std::endl;

                    return (i1 != i2 ? true : false);
                }


                static bool test5() {
                    
                    uint16_t i1 = 1092;
                    std::string s("1092");

                    uint16_t i2 = s2n<uint16_t>()(s);

                    std::cerr << "i2 = " << i2 << std::endl;

                    return (i1 == i2 ? true : false);
                }

                static bool test6() {
                    
                    uint16_t i1 = 1092;
                    const char * s("1092");

                    uint16_t i2 = s2n<uint16_t>()(s);

                    std::cerr << "i2 = " << i2 << std::endl;

                    return (i1 == i2 ? true : false);
                }

                static bool test7() {
                    
                    uint16_t i1 = 1092;
                    std::string s("12");

                    uint16_t i2 = s2n<uint16_t>()(s);

                    std::cerr << "i2 = " << i2 << std::endl;

                    return (i1 != i2 ? true : false);
                }

                static bool test8() {
                    
                    uint16_t i1 = 1092;
                    const char * s("92");

                    uint16_t i2 = s2n<uint16_t>()(s);

                    std::cerr << "i2 = " << i2 << std::endl;

                    return (i1 != i2 ? true : false);
                }

                static bool test9() {
                    
                    int32_t i1 = -94328430;
                    std::string s("-94328430");

                    int32_t i2 = s2n<int32_t>()(s);

                    std::cerr << "i2 = " << i2 << std::endl;

                    return (i1 == i2 ? true : false);
                }

                static bool test10() {
                    
                    uint32_t i1 = 77888832;
                    const char * s("77888832");

                    uint32_t i2 = s2n<uint32_t>()(s);

                    std::cerr << "i2 = " << i2 << std::endl;

                    return (i1 == i2 ? true : false);
                }

                static bool test11() {
                    
                    int32_t i1 = -948430;
                    std::string s("-4");

                    int32_t i2 = s2n<int32_t>()(s);

                    std::cerr << "i2 = " << i2 << std::endl;

                    return (i1 != i2 ? true : false);
                }

                static bool test12() {
                    
                    uint32_t i1 = 77888832;
                    const char * s("802");

                    uint32_t i2 = s2n<uint32_t>()(s);

                    std::cerr << "i2 = " << i2 << std::endl;

                    return (i1 != i2 ? true : false);
                }

                static bool test13() {
                    
                    int64_t i1 = -948439323209;
                    std::string s("-948439323209");

                    int64_t i2 = s2n<int64_t>()(s);

                    std::cerr << "i2 = " << i2 << std::endl;

                    return (i1 == i2 ? true : false);
                }

                static bool test14() {
                    
                    uint64_t i1 = 7788889323232;
                    const char * s("7788889323232");

                    uint64_t i2 = s2n<uint64_t>()(s);

                    std::cerr << "i2 = " << i2 << std::endl;

                    return (i1 == i2 ? true : false);
                }

                static bool test15() {
                    
                    int64_t i1 = -948439323209;
                    std::string s("9484393");

                    int64_t i2 = s2n<int64_t>()(s);

                    std::cerr << "i2 = " << i2 << std::endl;

                    return (i1 != i2 ? true : false);
                }

                static bool test16() {
                    
                    uint64_t i1 = 7788889323232;
                    const char * s("889323232");

                    uint64_t i2 = s2n<uint64_t>()(s);

                    std::cerr << "i2 = " << i2 << std::endl;

                    return (i1 != i2 ? true : false);
                }

                static bool test17() {
                    
                    uint64_t i1 = 7788889323232;
                    std::string s("889323232");

                    uint64_t i2 = s2n<uint64_t>()(std::move(s));

                    std::cerr << "i2 = " << i2 << std::endl;

                    return (i1 != i2 ? true : false);
                }

                static bool test18() {
                    
                    uint64_t i1 = 7788889323232;
                    const std::string s("7788889323232");

                    uint64_t i2 = s2n<uint64_t>()(s);

                    std::cerr << "i2 = " << i2 << std::endl;

                    return (i1 == i2 ? true : false);
                }

                static bool test19() {
                    
                    const std::string s("ola");

                    try {
                        
                        uint64_t i2 = s2n<uint64_t>()(s);

                        std::cerr << "i2 = " << i2 << std::endl;

                        return false;
                        
                    } catch (std::exception & l_ex) {
                        std::cout << "l_ex.what() "<< std::endl;
                        return true;
                    }
                }

            public:

                static void run() {
                    runtest(string2number_tester::test1());
                    runtest(string2number_tester::test2());
                    runtest(string2number_tester::test3());
                    runtest(string2number_tester::test4());

                    runtest(string2number_tester::test5());
                    runtest(string2number_tester::test6());
                    runtest(string2number_tester::test7());
                    runtest(string2number_tester::test8());

                    runtest(string2number_tester::test9());
                    runtest(string2number_tester::test10());
                    runtest(string2number_tester::test11());
                    runtest(string2number_tester::test12());

                    runtest(string2number_tester::test13());
                    runtest(string2number_tester::test14());
                    runtest(string2number_tester::test15());
                    runtest(string2number_tester::test16());

                    runtest(string2number_tester::test17());
                    runtest(string2number_tester::test18());

                    runtest(string2number_tester::test19());
                }

            };

            
        }
    }
}
